package cn.xyfmzmy;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Main {

    public static void main(String[] args) throws InterruptedException {

        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss SSS");
        // 创建定时任务类
        ScheduleService scheduleService = new ScheduleService();
        // 添加定时任务，间隔100ms
        System.out.println("创建定时任务1");
        scheduleService.schedule(()->{
            System.out.println(LocalDateTime.now().format(dateTimeFormatter) + " 100ms每次");
        },100);

        Thread.sleep(1000);
        System.out.println("创建定时任务2");
        // 添加定时任务，间隔200ms
        scheduleService.schedule(()->{
            System.out.println(LocalDateTime.now().format(dateTimeFormatter) + " 200ms每次");
        },200);
    }
}
